#!/bin/sh

## contributed by:
## "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
## Peter Zijlstra <peterz@infradead.org>

## updated by:
## "Wenzhong Sun" <wenzhong.sun@intel.com>
##  - Limit the test's runtime in 5 minutes
##  - Adapt test to use runtime_loop framework

CPUPATH="/sys/devices/system/cpu"

NUMBER_OF_CPUS=$(ls -d $CPUPATH/cpu[0-9]* | wc -l)

: "${runtime:=300}"

do_test()
{
	for interval in 0 0.1 1
	do
		for i in $(seq $((NUMBER_OF_CPUS - 1)))
		do
			sleep $interval
			state=$(cat $CPUPATH/cpu$i/online)
			echo $((state^1)) > $CPUPATH/cpu$i/online
		done
	done
}

. $LKP_SRC/lib/runtime_loop.sh
runtime_loop
